﻿<%@ Page Language="C#" ValidateRequest="false" EnableEventValidation="false"  AutoEventWireup="true" CodeBehind="IMForm.aspx.cs" Inherits="IWebApp2.IMForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
   <title>Untitled Page</title>
   
   
   
   <meta http-equiv="Page-Enter" content="Alpha(opacity=100)"> <!-- Remove the IE Flashing --> 
   <meta http-equiv="Page-Enter" content="blendTrans(Duration=0.1)"><!-- Remove the IE Flashing -->   
   <meta http-equiv="Page-Enter" content="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/spacer.png', sizingMethod=scale)">
   
   
   
    <!--javascripts used by this web forms-->
    <script type="text/javascript" src="JS-CSS/Menu.js"></script>
    <script type="text/javascript" src="JS-CSS/ContextMenu.js"></script>
   
    
    <!--scripts for calling web service method-->
    <!--ajax implementation specifically xmlHttp-->
    <script language="javascript" type="text/javascript">
    var xmlHttp; 
    //callFunction is used in Code Behind
    //parameter name contains contact nickname
    function callFunctions(name)
    {
     xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
     //pass name to web service RunChatBox, in order to create Winform chat window
     xmlHttp.open("get", "http://localhost:2640/ybWebSrvc.asmx/RunChatBox?formName="+name , true);
     xmlHttp.send(); return false; 
    }
    </script>
    
    
    
    
    
    <!--scripts for GUI only-->
    <!--specifically Menu, Context Menu and Profile PopUp window-->
    <script type="text/javascript">
    var oCustomContextMenu = null;
    var oBase = null; 
    var MessengerMenu =null;
    var ActionMenu=null;
    var HelpMenu=null;
    var frame=null;
    
    //on window load, load frame1, menu and context menu
    window.onload = function()
    {
        oBase = document.getElementById('div');
        frame=document.getElementById("frame1");
        var iFrame = document.getElementById('frame1');
        var flag=0;
        
        
        //this area is for iframe that displays contact profiles
        function watchFrame()
        {
            //check if the src=="blank.htm", if it is then hide it(iframe)
            if (flag!==1&&frame1.location.href.indexOf('blank.htm')!==-1) 
            {
            flag=1;
            Hide();
            }
        }
        //use to hide the frame for profile
        function Hide()
        {
            frame.style.visibility='hidden';  
            flag=0;
        }
        
        //add events to iframe 
        if (iFrame.attachEvent) 
            {
            iFrame.attachEvent('onmouseover', function() { watchFrame(); });
            } 
            else if (iFrame.addEventListener) 
            {
            iFrame.addEventListener('mouseover', function() { alert('addEventListener'); }, false);
            } 
            else 
            {
            iFrame.onmouseover = function() { alert('direct assignment'); };
            }
           
   
       //context menu, initial values
        var ContextArguments = {
            Base: oBase,
            Width: 120,                                        //sets the initial width of the context menu
            FontColor: null,
            HoverFontColor: null,
            HoverBackgroundColor: null,
            HoverBorderColor: null,
            ClickEventListener: OnContextClick
        };
        
        //messenger menu, initial values
        var MessengerArguments = {
            Base: oBase,
            left:6,
            subleft:150,
            ID:'Messenger',
            ClickEventListener: OnMessengerMenuClick
        };
        
        //action menu, initial values
        var ActionArguments = {
            Base: oBase,
            left:70,
            subleft:0,
            ID:'Action',
            ClickEventListener: OnActionMenuClick
        };
        
        //help menu, initial values
        var HelpArguments = {
            Base: oBase,
            left:130,
            subleft:0,
            ID:'Help',
            ClickEventListener: OnHelpMenuClick
        };
        
        //add items to context menu        
        oCustomContextMenu = new CustomContextMenu(ContextArguments); 
        oCustomContextMenu.AddItem('Images/sendmsg_white.png',10, 'Send Message', false, 'SendMessage');
        oCustomContextMenu.AddItem('Images/delete_white.png',10, 'Delete', false, 'Delete');
        oCustomContextMenu.AddItem('Images/avatar.png', 10,'View Profile', false, 'ViewProfile');
        oCustomContextMenu.AddItem('Images/online.png',10, 'Appear As..', false, 'AppearAs');
        
        //add menu items to Messenger menu
        MessengerMenu=new Menu(MessengerArguments);
        MessengerMenu.AddItem('Images/play.png', 10,'My Status', false, 'MyStatus');
        MessengerMenu.AddItem(' ', 10,'My Profile', false, 'MyProfile');
        MessengerMenu.AddItem(' ', 10,'My Status Message', false, 'MyStatusMessage');
        MessengerMenu.AddItem(' ', 10,'My Message Archive', false, 'MyMessageArchive');
        MessengerMenu.AddItem(' ', 10,'My Settings', false, 'MySettings');
        
        //add menu items to Action Menu
        ActionMenu=new Menu(ActionArguments);
        ActionMenu.AddItem(' ', 10,'Add Contact', false, 'AddContact');
        ActionMenu.AddItem(' ', 10,'Send an Email', false, 'SendEmail');
        ActionMenu.AddItem(' ', 10,'Edit my Profile', false, 'EditProfile');
        ActionMenu.AddItem(' ', 10,'Change my Password', false, 'ChangePassword');
        ActionMenu.AddItem(' ', 10,'Change my Avatar', false, 'ChangeAvatar');
        
        //add menu items to Help Menu
        HelpMenu=new Menu(HelpArguments);
        HelpMenu.AddItem(' ', 10,'Tutorial', false, 'Tutorial');
        HelpMenu.AddItem(' ', 10,'About Yehba', false, 'AboutYehba');
    }
    
    
    //(event) contextmenu was clicked    
    var OnContextClick = function(Sender, EventArgs)
    {
        //var x=document.getElementById('frame1');
        switch(EventArgs.CommandName)
        {
            case 'SendMessage':
                //working but not yet active
                break;
            case 'Delete':
                //working but not yet active
                break;
            case 'ViewProfile':
                //will display profile in an iframe
                //profileOf holds the name of the contact user wants to view profile
                var j=oCustomContextMenu.profileOf();
                PageMethods.ShowProfile(j);
                setTimeout ("CallProfile()", 1000 );
                break;
            case 'AppearAs':
             
               //oncontextmenu="javascript:return oCustomContextMenu.Display(event);"
               alert('Text: ' + EventArgs.Text);
               //alert('IsDisabled: ' + EventArgs.IsDisabled);
               //alert('ImageUrl: ' + EventArgs.ImageUrl);
               break;
        }
        
        oCustomContextMenu.Hide();   
    }
    
    //(event) Messenger menu was clicked
    var OnMessengerMenuClick = function(Sender, EventArgs)
    { 
      var stat=document.getElementById('status');
        switch(EventArgs.CommandName)
        {
           
            case 'MyProfile':
                {
                var m=null;
                m='<%=myNickName%>';
                //alert(m);
                PageMethods.ShowProfile(m);
                setTimeout ("CallProfile()", 1000 );

                break;
                }
            case 'MyStatusMessage':
                {
                stat.style.visibility='visible';
                stat.style.top='15px';
              
                break;
                }
            case 'MyMessageArchive':
                {
                alert("Hi");
                break;
                }
            case 'MySettings':
                {
                  alert("Hi");
                  break;
                }
       }
       MessengerMenu.Hide();   //*************
    }
   
    //(event) Action menu was clicked
    var OnActionMenuClick = function(Sender, EventArgs)
    {
        switch(EventArgs.CommandName)
        {
           
            case 'AddContact':
                {
                alert("hi");
                break;
                }
            case 'SendEmail':
                {
                alert("Hi");
                break;
                }
            case 'EditProfile':
                {
                alert("Hi");
                break;
                }
            case 'ChangePassword':
                {
                  alert("Hi");
                  break;
                }
            case 'ChangeAvatar':
                {
                  alert("Hi");
                  break;
                }    
       }
       ActionMenu.Hide();   //*************
    }
   
    //(event) Help menu was clicked
    var OnHelpMenuClick = function(Sender, EventArgs)
    {
        switch(EventArgs.CommandName)
        {
           
            case 'Tutorial':
                {
                alert("hi");
                break;
                }
            case 'AboutYehba':
                {
                alert("Hi");
                break;
                }
       }
       HelpMenu.Hide();   //*************
    }
   
     
   //displays the Profile in an iframe
   function CallProfile()
   {
   var x=document.getElementById('frame1');
   x.src="Profile.aspx";
   x.style.visibility='visible';
   }
     
    //on Window unload, Dispose script objects
    window.onunload = function()
    { 
    oCustomContextMenu.Dispose(); 
    ActionMenu.Dispose();
    HelpMenu.Dispose();
    MessengerMenu.Dispose();
    }

    
    function ShowMessenger()
    {
    MessengerMenu.Display();
    ActionMenu.Hide();
    HelpMenu.Hide();
    }
    
    function ShowAction()
    {
    ActionMenu.Display();
    MessengerMenu.HideAll();
    HelpMenu.Hide();
    }
    
    function ShowHelp()
    {
    HelpMenu.Display();
    ActionMenu.Hide();
    MessengerMenu.Hide();
    }
   </script>
   <!--scripts for GUI only-->

 
 
 
 
 
   <style type="text/css">
	/* START CSS only needed for this demo page */
	body{	/* Styling the body element */	
		font-family: Trebuchet MS, Lucida Sans Unicode, Arial, sans-serif;
		margin:0px;
		padding:0px;
		height:100%;
		font-size:0.9em;
		line-height:130%;
		background-color:#E2EBED;
	}	
	a{
		color:#D60808;
		text-decoration:none;
	}
	a:hover{
		text-decoration:underlin;
	}
	
	#chatFrame ul{
		padding-left:20px;
		margin-left:0px;
	}
	#chatFrame div{
		padding:3px;
	}
	#mainContent{
		width:660px;
		margin-left:150px;
		background-color:#FFF;
		padding-right:5px;
		border-left:1px solid #000;
		border-right:1px solid #000;
		border-bottom:1px solid #000;
		
	}

	/* END CSS ONLY NEEDED FOR THIS DEMO PAGE */
	
	#chatFrame{	/* Styling the help panel */
		
		/* background-color:#3c94c8;	Blue background color */
		/*color:#FFF;	 White text color */
		/*font-family: Trebuchet MS, Lucida Sans Unicode, Arial, sans-serif;	 Which font to use */
		
		/* You shouldn't change these 5 options unless you need to */		
		height:70%;		
		left:0px;
		z-index:10;
		margin-top:50px;
		position:absolute;
		display:none;
	}
	
	#chatFrame #leftPanelContent
	{  
		padding:0px;
		height:220px;   /*margin from top*/
		margin-top:70px;/*distance from top*/
	
	}
	#chatFrame .closeLink{ /* Layout of close link */
		padding-left:2px;
		padding-right:2px;
		background-color:#FFF;
		position:absolute;
		top:2px;
		right:2px;
		border:1px solid #000;
		color:#000;
		font-size:0.8em;				
	}
	#chatFrame .closeLink:hover{	/* Close link text  - mouseover effect*/
		color:#FFF;
		background-color:#000;
	}	
	
   #chatFrame
        {
            width: 251px;
            height: 400px;
        }
        table.floatingHeader
        {
	    background-color: #0000ff;
	    color:#ffffff;
        }
  
       .style1
       {
           width: 45px;
       }
 	   .style2
       {
           width: 47px;
       }
       .style3
       {
           width: 57px;
       }
       #buttons
       {
           height: 31px;
       }
 	   #frame1
       {
           margin-left: 13px;
           height: 244px;
       }
 	   #frame2
       {
           height: 41px;
           width: 171px;
       }
 	   #GridviewScroll
       {
           width: 228px;
       }
 	</style>




  
</head>
<body scroll="no">
   
  <form id="form1" runat="server" style="position: absolute; top: -4px; left: -14px;">
   
<div id="mainContent" 
      
      style="position: absolute; top: 4px; left: -139px; height: 360px; width: 652px; visibility: visible;">
   <div id="buttons" style="height: 21px; width: 650px; " 
        style="margin-left:2px">   
       
       
      <table id="buttontable" 
           style="width: 31%; height: 25px; margin-top: 0px; top: 1px; position: absolute; left: 6px;">
            <tr>
                <td class="style1">
                    <asp:Image ID="Image2" runat="server" BorderColor="#333333" onmouseover="ShowMessenger();" 
                        Height="15px" ImageUrl="~/Images/messenger3.png" style="margin-left: 0px" 
                        Width="53px" BorderStyle="Groove" BorderWidth="1px" />
                </td>
                <td class="style2">
                    <asp:Image ID="Image4" runat="server" BorderColor="#333333" 
                        Height="15px" ImageUrl="~/Images/actions3.png" style="margin-left: 0px" onmouseover="ShowAction();" 
                        Width="53px" BorderStyle="Groove" BorderWidth="1px" />
                </td>
                <td class="style3">
                    <asp:Image ID="Image5" runat="server" BorderColor="#333333" 
                        Height="15px" ImageUrl="~/Images/help3.png" style="margin-left: 0px" onmouseover="ShowHelp();" 
                        Width="53px" BorderStyle="Groove" BorderWidth="1px" />
                </td>
                <td class="style4">
                <asp:ImageButton ID="ImageButton2" runat="server" Height="15px" 
                        ImageUrl="~/Images/signout3.png" onclick="ImageButton1_Click" 
                        style="margin-left: 0px; " Width="53px" 
                        ToolTip="Sign Out" BorderStyle="Solid" BorderColor="#373737" 
                        BorderWidth="1px" />  
                </td>
                </table>
     
          </tr>
     
     
     
        <asp:Image ID="Image3" runat="server" BackColor="Black" Height="29px" 
            ImageUrl="~/Images/top-bar4.png" style="margin-left: 0px" 
           Width="254px" BorderColor="#003366" BorderStyle="Ridge" 
           BorderWidth="1px" />
     </div>
   <asp:ScriptManager ID="ScriptManager1" runat="server" 
       EnablePageMethods="True">
       <Services>
           <asp:ServiceReference Path="http://localhost:2640/ybWebSrvc.asmx" />
       </Services>
   </asp:ScriptManager>
<div id="GridviewScroll" style="overflow-y: scroll; height: 400px; ">  
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
       <ContentTemplate>
     
           <asp:GridView ID="GridView1" Runat="server" AutoGenerateColumns="False"  
               CellPadding="1" DataKeyNames="Contacts,JID" 
               EnableViewState="False" Font-Names="Arial" Font-Size="10px" 
               ForeColor="#444957" GridLines="None" Height="14px" style="margin-top: 0px; margin-left: 10px;" 
               Width="226px" onrowdatabound="GridView1_RowDataBound" ShowHeader="False" 
               onrowcreated="GridView1_RowCreated" >
               <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
               <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
               <HeaderStyle BackColor="White" Font-Bold="True" ForeColor="White" 
                   Height="2px" />
               <Columns>
                   <asp:ImageField DataImageUrlField="Status">
                       <ControlStyle Height="8px" Width="8px" />
                       <HeaderStyle Height="5px" />
                   </asp:ImageField>
                   <asp:BoundField DataField="JID" HeaderText="JID" />
                  
                   <asp:BoundField DataField="Contacts" HeaderText="Contacts" >
                       <HeaderStyle Height="5px" />
                   </asp:BoundField>
                  
             
                   <asp:ImageField DataImageUrlField="Avatar" HeaderText="Avatar">
                       <ControlStyle Height="20px" 
                           Width="20px" />
                       <HeaderStyle HorizontalAlign="Left" />
                       <ItemStyle Height="10px" HorizontalAlign="Left" />
                   </asp:ImageField>     
              
               </Columns>
               <EmptyDataTemplate>
                   &nbsp;
               </EmptyDataTemplate>
               <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
               <RowStyle BackColor="#EFF3FB" />
               <EditRowStyle BackColor="#2461BF" />
               <AlternatingRowStyle BackColor="White" />
           </asp:GridView>
           
     
           
        <input type="hidden" runat="server" id="hdnListElements" />
      
           <asp:Timer ID="Timer1" runat="server" Interval="1000" ontick="Timer1_Tick">
           </asp:Timer>
          
           &nbsp;
           &nbsp;
         
      
         
       </ContentTemplate>
       <Triggers>
           <asp:AsyncPostBackTrigger ControlID="GridView1" EventName="DataBinding" />
           <asp:AsyncPostBackTrigger ControlID="hdnListElements" 
               EventName="ServerChange" />
          
       </Triggers>
   </asp:UpdatePanel>
         </div>  
</div>
        <p>&nbsp;</p><p>&nbsp;</p><p></p>
        
    <iframe id="frame1" src="Profile.aspx" frameborder="0" 
    marginheight="0" marginwidth="0" scrolling="no" 
    style="display: block; z-index: 100000; position: absolute; top: 117px; left: 0px; width: 302px; visibility: hidden;" 
    width="194">
    </iframe>
        
       
       <div ID="status" 
            
            style="border: 3px ridge #CCCCCC; width: 195px; height: 40px; z-index: 100000; background-image: url('Images/textbox_bg3.png'); font-size: 9px; font-style: italic; visibility: hidden; display: block; top: 15px;">
               &nbsp;&nbsp;&nbsp; Edit new status message&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ht="16px" 
                   OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" 
                   ontextchanged="DropDownList1_TextChanged" 
                   style="margin-left: 8px; margin-top: 0px; margin-bottom: 0px" Width="160px">
                   <asp:ListItem Value="Item 2">Item 2</asp:ListItem>
                   <asp:ListItem Value="Item 3">Item 3</asp:ListItem>
                   <asp:ListItem Value="Item 4">Item 4</asp:ListItem>
               </asp:DropDownList>
               <asp:ImageButton ID="ImageButton5" runat="server" 
                   ImageUrl="~/Images/close_icon2.png" style="margin-left: 7px" />
               &nbsp;
        </div>    
       
</form>   
        
</body>
</html>
